package com.ruoyi.system.outto.goods.impl;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.ruoyi.common.constant.Constants;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.exception.GlobalException;
import com.ruoyi.common.utils.SecuritySHA1Utils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.http.HttpUtils;
import com.ruoyi.system.V2.gameAttr.mapper.GameAttributeMapper;
import com.ruoyi.system.V2.goodInfo.mapper.GoodsInfoImgMapper;
import com.ruoyi.system.V2.inter.mapper.ArtRecMapper;
import com.ruoyi.system.model.domain.*;
import com.ruoyi.system.model.dto.GoodsInfoAndAttrValueDto;
import com.ruoyi.system.model.mapper.AccountInfoMapper;
import com.ruoyi.system.model.mapper.InfoImgMapper;
import com.ruoyi.system.outto.core.LCConstant;
import com.ruoyi.system.outto.core.MapUntils;
import com.ruoyi.system.outto.dto.LDConstant;
import com.ruoyi.system.outto.game.CommonApi;
import com.ruoyi.system.outto.game.LDV2API;
import com.ruoyi.system.outto.goods.NEWLDV2API;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.beanutils.ConvertUtils;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;

/**
 * @author lz
 * @version 1.0
 * @date 2022/6/5 16:19
 */
@Slf4j
@Service
public class NEWLDV2APIImpl implements NEWLDV2API {

    @Resource
    private InfoImgMapper infoImgMapper;
    @Value("${desc.title}")
    private String descTitle;
    //    private SalePartner salePartner;
    @Resource
    private CommonApi commonApi;

    @Resource
    private AccountInfoMapper accountInfoMapper;
    @Resource
    private GameAttributeMapper gameAttributeMapper;
    @Resource
    private ArtRecMapper artRecMapper;
    @Resource
    private GoodsInfoImgMapper goodsInfoImgMapper;


    @Override
    public AjaxResult addGame(GoodsInfoAndAttrValueDto goodsInfoAndAttrValueDto, SalePartner salePartner) {

        String path = "api/goods/platform/release";
//        this.salePartner = salePartner;
        Map<String, Object> result = new HashMap<>();
        Map<String, Object> params = params(goodsInfoAndAttrValueDto, salePartner,"add");
        log.info("老达代售添加接口请求参数={}", params);
        String response = HttpUtils.doPostForm(salePartner.getTwoOther() + path, params, null);
        log.info("老达代售添加接口返回参数={}", response);
        JSONObject resultJson = JSONObject.parseObject(response);
        if (!"1".equals(resultJson.getString("code"))) {
            result.put("code", 500);
        } else {
            result.put("code", 200);
//            {"code":1,"msg":"添加成功","time":1677939248,"data":{"id":"54554"}}
            String data = resultJson.getString("data");
            if (StringUtils.isNotEmpty(data)) {
                JSONObject jsonObject = JSON.parseObject(data);
                String product_id = jsonObject.getString("id");

                ArtRec artRecreq = new ArtRec();
                artRecreq.setConfig(salePartner.getId());
                artRecreq.setAccountId(goodsInfoAndAttrValueDto.getId());
                List<ArtRec> artRecs = artRecMapper.selectArtRecList(artRecreq);
                if(artRecs.size()>0) {
                    artRecs.get(0).setOutid(product_id);
                    artRecMapper.updateArtRec(artRecs.get(0));
                }else{
                    artRecreq.setAccountId(goodsInfoAndAttrValueDto.getId());
                    artRecreq.setCreateId(goodsInfoAndAttrValueDto.getCreateId());
                    artRecreq.setType(LCConstant.interAdd);
                    artRecreq.setConfig(salePartner.getId());
                    artRecreq.setSaleCode(salePartner.getSaleName());
                    artRecreq.setOutid(product_id);
                    artRecMapper.insertArtRec(artRecreq);
                }

                String rand_str = rand_str();
                Map<String, Object> paramsUp = new LinkedHashMap<>();
                paramsUp.put("appid", salePartner.getSaleKey());
                paramsUp.put("secret", salePartner.getOther());
                paramsUp.put("rand_str", rand_str);
                paramsUp.put("timestamp", new Date().getTime() / 1000);
                String cover = MapUntils.getCover(paramsUp);
                cover = cover.substring(0, cover.length() - 1);
                log.info("cover={}", cover);
                String sign = DigestUtils.md5Hex(cover);
                String sr = sign + rand_str;
                try {
                    sr = SecuritySHA1Utils.shaEncode(sr);
                } catch (Exception e) {
                    e.printStackTrace();
                }
                paramsUp.put("sign", sr);
                ArtRec artRecreq1 = new ArtRec();
                artRecreq1.setConfig(salePartner.getId());
                artRecreq1.setAccountId(goodsInfoAndAttrValueDto.getId());
                List<ArtRec> artRecs1 = artRecMapper.selectArtRecList(artRecreq);
                if(artRecs1.size()>0) {
                    paramsUp.put("id", artRecs1.get(0).getOutid());
                }
                String pathUp = "api/goods/platform/upper";
                paramsUp.put("code", goodsInfoAndAttrValueDto.getId());
                log.info("老达上架接口请求参数={}", JSONObject.toJSONString(params));
                HttpUtils.doPostForm(salePartner.getTwoOther() + pathUp, paramsUp, null);
                if (StringUtils.isEmpty(response)) {
                    throw new GlobalException("请求接口失败");
                }
                log.info("老达上架接口返回参数={}", JSONObject.toJSONString(response));
            }
        }

        result.put("req", JSONObject.toJSONString(params));
        result.put("res", response);
        result.put("msg", resultJson.getString("data"));

        return AjaxResult.success(result);
    }

    @Override
    public AjaxResult editGame(GoodsInfoAndAttrValueDto goodsInfoAndAttrValueDto, SalePartner salePartner) {
        String path = "api/goods/platform/release";
//        this.salePartner = salePartner;
        Map<String, Object> result = new HashMap<>();
        Map<String, Object> params = params(goodsInfoAndAttrValueDto, salePartner,"edit");
        log.info("老达编辑接口请求参数={}", JSONObject.toJSONString(params));
        String response = HttpUtils.doPostForm(salePartner.getTwoOther() + path, params, null);
        log.info("老达编辑接口返回参数={}", response);
        JSONObject resultJson = JSONObject.parseObject(response);

        if (!"1".equals(resultJson.getString("code"))) {
            result.put("code", 500);
        } else {
            result.put("code", 200);

        }


        result.put("req", JSONObject.toJSONString(params));
        result.put("res", response);
        result.put("msg", resultJson.getString("data"));
        return AjaxResult.success(result);
    }


    private Map<String, Object> params(GoodsInfoAndAttrValueDto goodsInfoAndAttrValueDto, SalePartner salePartner,String type) {
        GameAttribute gameAttribute = null;
        String regional = "";
        if(goodsInfoAndAttrValueDto.getGameName().contains("王者荣耀")){
            regional=goodsInfoAndAttrValueDto.getSystemName()+goodsInfoAndAttrValueDto.getCarrierName();
            gameAttribute = gameAttributeMapper.selectGameAttributeById(Long.valueOf(goodsInfoAndAttrValueDto.getF16()));
        }else if(goodsInfoAndAttrValueDto.getGameName().contains("和平精英")){
            regional=goodsInfoAndAttrValueDto.getSystemName()+goodsInfoAndAttrValueDto.getCarrierName();
            gameAttribute = gameAttributeMapper.selectGameAttributeById(Long.valueOf(goodsInfoAndAttrValueDto.getF10()));
        }else if(goodsInfoAndAttrValueDto.getGameName().contains("原神")){
            regional=goodsInfoAndAttrValueDto.getCarrierName();
            gameAttribute = gameAttributeMapper.selectGameAttributeById(Long.valueOf(goodsInfoAndAttrValueDto.getF20()));
        }else if(goodsInfoAndAttrValueDto.getGameName().contains("穿越火线")){
            regional=goodsInfoAndAttrValueDto.getGroupName();
            gameAttribute = gameAttributeMapper.selectGameAttributeById(Long.valueOf(goodsInfoAndAttrValueDto.getF3()));
        }else if(goodsInfoAndAttrValueDto.getGameName().contains("光遇")){//=================================未配置游戏属性
            gameAttribute = gameAttributeMapper.selectGameAttributeById(Long.valueOf(goodsInfoAndAttrValueDto.getF20()));
        }else if(goodsInfoAndAttrValueDto.getGameName().contains("英雄联盟")){
            regional=goodsInfoAndAttrValueDto.getServerName();
            gameAttribute = gameAttributeMapper.selectGameAttributeById(Long.valueOf(goodsInfoAndAttrValueDto.getF1()));
        }else if(goodsInfoAndAttrValueDto.getGameName().contains("火影忍者")){
            gameAttribute = gameAttributeMapper.selectGameAttributeById(Long.valueOf(goodsInfoAndAttrValueDto.getF7()));
        }else{
            throw new GlobalException("当前游戏暂不支持");
        }
        String rand_str = rand_str();
        Map<String, Object> params = new LinkedHashMap<>();
        params.put("appid", salePartner.getSaleKey());
        params.put("secret", salePartner.getOther());
        params.put("rand_str", rand_str);
        params.put("timestamp", new Date().getTime() / 1000);
        String cover = MapUntils.getCover(params);
        cover = cover.substring(0, cover.length() - 1);
        log.info("cover={}", cover);
        String sign = DigestUtils.md5Hex(cover);
        String sr = sign + rand_str;
        try {
            sr = SecuritySHA1Utils.shaEncode(sr);
        } catch (Exception e) {
            e.printStackTrace();
        }
        params.put("sign", sr);
        if(!"add".equals(type)) {
            ArtRec artRecreq = new ArtRec();
            artRecreq.setConfig(salePartner.getId());
            artRecreq.setAccountId(goodsInfoAndAttrValueDto.getId());
            List<ArtRec> artRecs = artRecMapper.selectArtRecList(artRecreq);
            params.put("id", artRecs.get(0).getOutid());
        }
        params.put("code", goodsInfoAndAttrValueDto.getId());

        JSONObject property = new JSONObject();

        if (Objects.equals("王者荣耀", goodsInfoAndAttrValueDto.getGameName())) {

            params.put("game_id", 663);

            if (Objects.equals("安卓QQ", goodsInfoAndAttrValueDto.getSystemName()+goodsInfoAndAttrValueDto.getCarrierName())) {
                params.put("server_id", 70582);
            } else if (Objects.equals("安卓微信", goodsInfoAndAttrValueDto.getSystemName()+goodsInfoAndAttrValueDto.getCarrierName())) {
                params.put("server_id", 71058);
            } else if (Objects.equals("苹果微信", goodsInfoAndAttrValueDto.getSystemName()+goodsInfoAndAttrValueDto.getCarrierName())) {
                params.put("server_id", 71536);
            } else if (Objects.equals("苹果QQ", goodsInfoAndAttrValueDto.getSystemName()+goodsInfoAndAttrValueDto.getCarrierName())) {
                params.put("server_id", 71402);
            }
            property.put("f1", "我是号主");
            property.put("f2", gameAttribute.getFieldName());
            if(StringUtils.isNotEmpty(goodsInfoAndAttrValueDto.getF3())) {
                GameAttribute gameAttribute1 = gameAttributeMapper.selectGameAttributeById(Long.valueOf(goodsInfoAndAttrValueDto.getF3()));
                if (gameAttribute1.getFieldName().contains("青铜")) {
                    property.put("f3", "倔强青铜");
                } else if (gameAttribute1.getFieldName().contains("白银")) {
                    property.put("f3", "秩序白银");
                } else if (gameAttribute1.getFieldName().contains("黄金")) {
                    property.put("f3", "荣耀黄金");
                } else if (gameAttribute1.getFieldName().contains("铂金")) {
                    property.put("f3", "尊贵铂金");
                } else if (gameAttribute1.getFieldName().contains("钻石")) {
                    property.put("f3", "永恒钻石");
                } else if (gameAttribute1.getFieldName().contains("星耀")) {
                    property.put("f3", "至尊星耀");
                } else if (gameAttribute1.getFieldName().contains("最强王者")) {
                    property.put("f3", "最强王者");
                } else {
                    property.put("f3", "荣耀王者");
                }
            }else{
                property.put("f3", "倔强青铜");
            }
            if(StringUtils.isNotEmpty(goodsInfoAndAttrValueDto.getF2())){
                GameAttribute gameAttribute2 = gameAttributeMapper.selectGameAttributeById(Long.valueOf(goodsInfoAndAttrValueDto.getF2()));
                property.put("f4", gameAttribute2.getFieldName());
            }else {
                property.put("f4", "无");
            }
            property.put("f5", goodsInfoAndAttrValueDto.getF17());
            property.put("f6", goodsInfoAndAttrValueDto.getF7());
            property.put("f7", goodsInfoAndAttrValueDto.getF8());
            if(StringUtils.isNotEmpty(goodsInfoAndAttrValueDto.getF18())){
                property.put("f8", goodsInfoAndAttrValueDto.getF18());
            }
            property.put("f9", goodsInfoAndAttrValueDto.getF4());
            List<String> dcList = new ArrayList<>();
            List<String> xyList = new ArrayList<>();
            List<String> csList = new ArrayList<>();
            List<String> xdList = new ArrayList<>();
            List<String> yzList = new ArrayList<>();
            List<String> yxList = new ArrayList<>();
            String pfIds = "";
            pfIds = reIds(pfIds, goodsInfoAndAttrValueDto.getF5());
            pfIds = reIds(pfIds, goodsInfoAndAttrValueDto.getF9());
            pfIds = reIds(pfIds, goodsInfoAndAttrValueDto.getF10());
            pfIds = reIds(pfIds, goodsInfoAndAttrValueDto.getF11());
            pfIds = reIds(pfIds, goodsInfoAndAttrValueDto.getF12());
            pfIds = reIds(pfIds, goodsInfoAndAttrValueDto.getF15());
            List<GameAttribute> gameAttributes = getGameAttributs(pfIds);
            JSONObject jsonObject = JSONObject.parseObject(JSONObject.parseObject(getAtta("663")).getString("data"));
            JSONObject jsonArray10 = JSONObject.parseObject(jsonObject.getString("f10"));
            JSONArray jsonArray2 = JSONArray.parseArray(jsonArray10.getString("options"));
            for(Object q : jsonArray2){
                for(GameAttribute gameAttribute11 : gameAttributes){
                    if(gameAttribute11.getFieldName().contains(q.toString())){
                        dcList.add(q.toString());
                    }
                }
            }
            JSONObject jsonObject11 = JSONObject.parseObject(jsonObject.getString("f11"));
            JSONArray jsonArray3 = JSONArray.parseArray(jsonObject11.getString("options"));
            for(Object q : jsonArray3){
                for(GameAttribute gameAttribute11 : gameAttributes){
                    if(gameAttribute11.getFieldName().contains(q.toString())){
                        xyList.add(q.toString());
                    }
                }
            }
            JSONObject jsonObject12 = JSONObject.parseObject(jsonObject.getString("f12"));
            JSONArray jsonArray4 = JSONArray.parseArray(jsonObject12.getString("options"));
            for(Object q : jsonArray4){
                for(GameAttribute gameAttribute11 : gameAttributes){
                    if(gameAttribute11.getFieldName().contains("刘备-时之恋人")){
                        gameAttribute11.setFieldName("时之恋人(男)");
                    }
                    if(gameAttribute11.getFieldName().contains("孙尚香-时之恋人")){
                        gameAttribute11.setFieldName("时之恋人(女)");
                    }
                    if(gameAttribute11.getFieldName().contains("小乔-音你心动")){
                        gameAttribute11.setFieldName("音你心动(女)");
                    }
                    if(gameAttribute11.getFieldName().contains("周瑜-音你心动")){
                        gameAttribute11.setFieldName("音你心动(男)");
                    }
                    if(gameAttribute11.getFieldName().contains("云中君-时之祈愿")){
                        gameAttribute11.setFieldName("时之祈愿男");
                    }
                    if(gameAttribute11.getFieldName().contains("瑶-时之祈愿")){
                        gameAttribute11.setFieldName("时之祈愿女");
                    }
                    if(gameAttribute11.getFieldName().contains(q.toString())){
                        csList.add(q.toString());
                    }
                }
            }
            JSONObject jsonObject13 = JSONObject.parseObject(jsonObject.getString("f13"));
            JSONArray jsonArray5 = JSONArray.parseArray(jsonObject13.getString("options"));
            for(Object q : jsonArray5){
                for(GameAttribute gameAttribute11 : gameAttributes){
                    if(gameAttribute11.getFieldName().contains("孙悟空-零号·赤焰")){
                        gameAttribute11.setFieldName("孙悟空-零号·赤炎");
                    }
                    if(gameAttribute11.getFieldName().contains("项羽-霸王别姬")){
                        gameAttribute11.setFieldName("霸王别姬(男)");
                    }
                    if(gameAttribute11.getFieldName().contains("虞姬-霸王别姬")){
                        gameAttribute11.setFieldName("霸王别姬(女)");
                    }
                    if(gameAttribute11.getFieldName().contains("兰陵王-默契交锋")){
                        gameAttribute11.setFieldName("默契交锋(男)");
                    }
                    if(gameAttribute11.getFieldName().contains("花木兰-默契交锋")){
                        gameAttribute11.setFieldName("默契交锋(女)");
                    }
                    if(gameAttribute11.getFieldName().contains("大乔-白鹤梁神女")){
                        gameAttribute11.setFieldName("白鹤梁神女");
                    }
                    if(gameAttribute11.getFieldName().contains(q.toString())){
                        xdList.add(q.toString());
                    }
                }
            }
            JSONObject jsonObject14 = JSONObject.parseObject(jsonObject.getString("f14"));
            JSONArray jsonArray6 = JSONArray.parseArray(jsonObject14.getString("options"));
            for(Object q : jsonArray6){
                for(GameAttribute gameAttribute11 : gameAttributes){
                    if(gameAttribute11.getFieldName().contains("后羿-如梦令")){
                        gameAttribute11.setFieldName("如梦令(男)");
                    }
                    if(gameAttribute11.getFieldName().contains("嫦娥-如梦令")){
                        gameAttribute11.setFieldName("如梦令(女)");
                    }
                    if(gameAttribute11.getFieldName().contains("孙策-猫狗日记")){
                        gameAttribute11.setFieldName("猫狗日记(男)");
                    }
                    if(gameAttribute11.getFieldName().contains("大乔-猫狗日记")){
                        gameAttribute11.setFieldName("猫狗日记(女)");
                    }
                    if(gameAttribute11.getFieldName().contains("镜-匿光追影者")){
                        gameAttribute11.setFieldName("逆光追影者");
                    }
                    if(gameAttribute11.getFieldName().contains(q.toString())){
                        yzList.add(q.toString());
                    }
                }
            }
            JSONObject jsonObject15 = JSONObject.parseObject(jsonObject.getString("f15"));
            JSONArray jsonArray7 = JSONArray.parseArray(jsonObject15.getString("options"));
            for(Object q : jsonArray7){
                for(GameAttribute gameAttribute11 : gameAttributes){
                    if(gameAttribute11.getFieldName().contains(q.toString())){
                        yxList.add(q.toString());
                    }
                }
            }
            if(dcList.size()>0) {
                property.put("f10", dcList.toArray());
            }
            if(xyList.size()>0) {
                property.put("f11", xyList.toArray());
            }
            if(csList.size()>0) {
                property.put("f12", csList.toArray());
            }
            if(xdList.size()>0) {
                property.put("f13", xdList.toArray());
            }
            if(xdList.size()>0) {
                property.put("f14", yzList.toArray());
            }
            if(yxList.size()>0) {
                property.put("f15", yxList.toArray());
            }
        }
        if (Objects.equals("和平精英", goodsInfoAndAttrValueDto.getGameName())) {
            params.put("game_id", 204);

            if (Objects.equals("安卓QQ", goodsInfoAndAttrValueDto.getSystemName()+goodsInfoAndAttrValueDto.getCarrierName())) {
                params.put("server_id", 23401);
            } else if (Objects.equals("安卓微信", goodsInfoAndAttrValueDto.getSystemName()+goodsInfoAndAttrValueDto.getCarrierName())) {
                params.put("server_id", 23404);
            } else if (Objects.equals("苹果微信", goodsInfoAndAttrValueDto.getSystemName()+goodsInfoAndAttrValueDto.getCarrierName())) {
                params.put("server_id", 23410);
            } else if (Objects.equals("苹果QQ", goodsInfoAndAttrValueDto.getSystemName()+goodsInfoAndAttrValueDto.getCarrierName())) {
                params.put("server_id", 23407);
            }

            property.put("f1", "我是号主");
            property.put("f2", gameAttribute.getFieldName().replace("可","能"));
            if(StringUtils.isNotEmpty(goodsInfoAndAttrValueDto.getF11())){
                property.put("f3", goodsInfoAndAttrValueDto.getF11());
            }
            if(StringUtils.isNotEmpty(goodsInfoAndAttrValueDto.getF12())) {
                property.put("f4", goodsInfoAndAttrValueDto.getF12());
            }
            if(StringUtils.isNotEmpty(goodsInfoAndAttrValueDto.getF8())) {
                property.put("f5", goodsInfoAndAttrValueDto.getF8());
            }
            if(StringUtils.isNotEmpty(goodsInfoAndAttrValueDto.getF9())) {
                property.put("f6", goodsInfoAndAttrValueDto.getF9());
            }
            String pfIds = "";
            pfIds = reIds(pfIds, goodsInfoAndAttrValueDto.getF1());
            pfIds = reIds(pfIds, goodsInfoAndAttrValueDto.getF2());
            pfIds = reIds(pfIds, goodsInfoAndAttrValueDto.getF5());
            List<GameAttribute> gameAttributes = getGameAttributs(pfIds);
            List<String> zjList = new ArrayList<>();
            List<String> tzList = new ArrayList<>();
            List<String> tz2List = new ArrayList<>();
            List<String> qxList = new ArrayList<>();
            JSONObject jsonObject = JSONObject.parseObject(JSONObject.parseObject(getAtta("204")).getString("data"));
            JSONObject jsonObject7 = JSONObject.parseObject(jsonObject.getString("f7"));
            JSONArray jsonArray2 = JSONArray.parseArray(jsonObject7.getString("options"));
            for(Object q : jsonArray2){
                String qName = q.toString();
                if(q.toString().contains("空客H135")){
                    qName = q.toString().replace("H135-","");
                }else if(q.toString().contains("特斯拉Roadster")){
                    qName = q.toString().replace("oadster","");
                }else if(q.toString().contains("特斯拉Cybertruck")){
                    qName = q.toString().replace("ybertruck","");
                }else if(q.toString().contains("塞莎KL27")){
                    qName = q.toString().replace("KL27","");
                }
                for(GameAttribute  gameAttribute1:gameAttributes){
                    String fieldName = gameAttribute1.getFieldName();
                    if(fieldName.contains("特斯拉3")){
                        fieldName = "Model3";
                    }else if(fieldName.contains("特斯拉X")){
                        fieldName = "ModelX";
                    }else if(fieldName.contains("阿斯顿马丁")){
                        fieldName = fieldName.replace("阿斯顿马丁","阿斯顿马丁DB");
                    }else if(fieldName.contains("兰博轿车灰色")){
                        fieldName = "兰博基尼Estoque银翼灰";
                    }else if(fieldName.contains("兰博轿车金色")){
                        fieldName = "兰博基尼Estoque炫光金";
                    }else if(fieldName.contains("兰博轿车尊享铂")){
                        fieldName = "兰博基尼Estoque尊享铂";
                    }else if(fieldName.contains("兰博SVJ绿色")){
                        fieldName = "兰博基尼AventadorSVJ翡翠绿";
                    }else if(fieldName.contains("兰博SVJ尊享铂")){
                        fieldName = "兰博基尼AventadorSVJ尊享铂";
                    }else if(fieldName.contains("兰博SUV黄色")){
                        fieldName = "兰博基尼URUS明艳黄";
                    }else if(fieldName.contains("兰博SUV金色")){
                        fieldName = "兰博基尼URUS炫光金";
                    }else if(fieldName.contains("兰博SUV尊享铂")){
                        fieldName = "兰博基尼URUS尊享铂";
                    }
                    if(fieldName.contains(qName)||qName.contains(fieldName)){
                        zjList.add(q.toString());
                    }
                }
            }
            JSONObject jsonArray8 = JSONObject.parseObject(jsonObject.getString("f8"));
            JSONArray jsonArray3 = JSONArray.parseArray(jsonArray8.getString("options"));
            for(Object q : jsonArray3){
                for(GameAttribute gameAttribute1 : gameAttributes){
                    if(gameAttribute1.getFieldName().replace("-","").contains(q.toString().replace("-",""))
                            ||q.toString().replace("-","").contains(gameAttribute1.getFieldName().replace("-",""))){
                        tzList.add(q.toString());
                    }
                }
            }
            JSONObject jsonArray9 = JSONObject.parseObject(jsonObject.getString("f9"));
            JSONArray jsonArray4 = JSONArray.parseArray(jsonArray9.getString("options"));
            for(Object q : jsonArray4){
                for(GameAttribute gameAttribute1 : gameAttributes){
                    if(gameAttribute1.getFieldName().replace("-","").contains(q.toString().replace("-",""))||
                    q.toString().replace("-","").contains(gameAttribute1.getFieldName().replace("-",""))){
                        tz2List.add(q.toString());
                    }
                }
            }
            JSONObject jsonArray10 = JSONObject.parseObject(jsonObject.getString("f10"));
            JSONArray jsonArray5 = JSONArray.parseArray(jsonArray10.getString("options"));
            for(Object q : jsonArray5){
                for(GameAttribute gameAttribute1 : gameAttributes){
                    if(gameAttribute1.getFieldName().replace("-","").contains(q.toString().replace("-",""))||
                            q.toString().replace("-","").contains(gameAttribute1.getFieldName().replace("-",""))){
                        qxList.add(q.toString());
                    }
                }
            }
            if(zjList.size()>0){
                property.put("f7", zjList.toArray());
            }
            if(tzList.size()>0){
                property.put("f8", tzList.toArray());
            }
            if(tz2List.size()>0){
                property.put("f9", tz2List.toArray());
            }
            if(qxList.size()>0){
                property.put("f10", qxList.toArray());
            }
        }
        if (Objects.equals("穿越火线", goodsInfoAndAttrValueDto.getGameName())) {
            params.put("game_id", 59);

            String cf = LDConstant.cf;
            JSONObject jsonObject = JSONObject.parseObject(cf);
            String data = jsonObject.getString("data");
            List<JSONObject> jsonObjects = JSONObject.parseArray(data, JSONObject.class);
            for (JSONObject object : jsonObjects) {
                String name = object.getString("name");
                if (Objects.equals(name, goodsInfoAndAttrValueDto.getGroupName().replace("北部战区","北部大区"))) {
                    String servers = object.getString("servers");
                    List<JSONObject> serversList = JSONObject.parseArray(servers, JSONObject.class);
                    for (JSONObject server : serversList) {
                        String name1 = server.getString("name");
//                        name1 = name1.substring(0, 2);
                        if (goodsInfoAndAttrValueDto.getServerName().contains(name1)) {
                            String id = server.getString("id");
                            params.put("server_id", id);
                        }
                    }
                }
            }

            property.put("f1", goodsInfoAndAttrValueDto.getGroupName().replace("战","大"));

            property.put("f2", "是");
            String pfIds = "";
            pfIds = reIds(pfIds, goodsInfoAndAttrValueDto.getF12());
            pfIds = reIds(pfIds, goodsInfoAndAttrValueDto.getF13());
            pfIds = reIds(pfIds, goodsInfoAndAttrValueDto.getF14());
            pfIds = reIds(pfIds, goodsInfoAndAttrValueDto.getF15());
            pfIds = reIds(pfIds, goodsInfoAndAttrValueDto.getF16());
            pfIds = reIds(pfIds, goodsInfoAndAttrValueDto.getF17());
            pfIds = reIds(pfIds, goodsInfoAndAttrValueDto.getF18());
            pfIds = reIds(pfIds, goodsInfoAndAttrValueDto.getF19());
            pfIds = reIds(pfIds, goodsInfoAndAttrValueDto.getF20());
            List<GameAttribute> gameAttributes = getGameAttributs(pfIds);
            List<String> jsList = new ArrayList<>();
            List<String> yxkList = new ArrayList<>();
            List<String> ndtList = new ArrayList<>();
            List<String> xjList = new ArrayList<>();
            List<String> wqList = new ArrayList<>();
            List<String> pfList = new ArrayList<>();
            JSONObject data1 = JSONObject.parseObject(JSONObject.parseObject(getAtta("59")).getString("data"));
            JSONObject f3 = JSONObject.parseObject(data1.getString("f3"));
            JSONArray jsonArray2 = JSONArray.parseArray(f3.getString("options"));
            for(Object q: jsonArray2){
                for(GameAttribute gameAttribute1: gameAttributes){
                    if(gameAttribute1.getFieldName().replace("-","").contains(q.toString().replace("-",""))||
                            q.toString().replace("-","").contains(gameAttribute1.getFieldName().replace("-",""))){
                        jsList.add(q.toString());
                    }
                }
            }
            JSONObject f4 = JSONObject.parseObject(data1.getString("f4"));
            JSONArray jsonArray3 = JSONArray.parseArray(f4.getString("options"));
            for(Object q: jsonArray3){
                for(GameAttribute gameAttribute1: gameAttributes){
                    if(gameAttribute1.getFieldName().contains(q.toString())||q.toString().contains(gameAttribute1.getFieldName())){
                        yxkList.add(q.toString());
                    }
                }
            }
            JSONObject f5 = JSONObject.parseObject(data1.getString("f5"));
            JSONArray jsonArray4 = JSONArray.parseArray(f5.getString("options"));
            for(Object q: jsonArray4){
                for(GameAttribute gameAttribute1: gameAttributes){
                    if(gameAttribute1.getFieldName().contains(q.toString().replace("套",""))){
                        ndtList.add(q.toString());
                    }
                }
            }
            JSONObject f6 = JSONObject.parseObject(data1.getString("f6"));
            JSONArray jsonArray5 = JSONArray.parseArray(f6.getString("options"));
            for(Object q: jsonArray5){
                for(GameAttribute gameAttribute1: gameAttributes){
                    if(gameAttribute1.getFieldName().replace("-","").contains(q.toString().replace("-",""))||
                            q.toString().replace("-","").contains(gameAttribute1.getFieldName().replace("-",""))){
                        xjList.add(q.toString());
                    }
                }
            }
            JSONObject f7 = JSONObject.parseObject(data1.getString("f7"));
            JSONArray jsonArray6 = JSONArray.parseArray(f7.getString("options"));
            for(Object q: jsonArray6){
                for(GameAttribute gameAttribute1: gameAttributes){
                    if(gameAttribute1.getFieldName().replace("-","").contains(q.toString().replace("-",""))||
                            q.toString().replace("-","").contains(gameAttribute1.getFieldName().replace("-",""))){
                        wqList.add(q.toString());
                    }
                }
            }
            JSONObject f8 = JSONObject.parseObject(data1.getString("f8"));
            JSONArray jsonArray7 = JSONArray.parseArray(f8.getString("options"));
            for(Object q: jsonArray7){
                for(GameAttribute gameAttribute1: gameAttributes){
                    if(gameAttribute1.getFieldName().replace("-","").contains(q.toString().replace("-",""))||
                            q.toString().replace("-","").contains(gameAttribute1.getFieldName().replace("-",""))){
                        pfList.add(q.toString());
                    }
                }
            }
            if(jsList.size()>0) {
                property.put("f3",jsList.toArray());
            }
            if(yxkList.size()>0) {
                property.put("f4",yxkList.toArray());
            }
            if(ndtList.size()>0) {
                property.put("f5",ndtList.toArray());
            }
            if(xjList.size()>0) {
                property.put("f6",xjList.toArray());
            }
            if(wqList.size()>0) {
                property.put("f7",wqList.toArray());
            }
            if(pfList.size()>0) {
                property.put("f8",pfList.toArray());
            }

        }
//        AccountInfo accountInfo = new AccountInfo();
        if (Objects.equals("原神", goodsInfoAndAttrValueDto.getGameName())) {
            params.put("game_id", 809);
            if (Objects.equals("游戏官方", goodsInfoAndAttrValueDto.getCarrierName())) {
                property.put("f1", "官服-天空岛服");
                params.put("server_id", 92461);
            }
            if (Objects.equals("哔哩哔哩", goodsInfoAndAttrValueDto.getCarrierName())) {
                params.put("server_id", 92464);
                property.put("f1", "B服-世界树服");
            }
            if (gameAttribute.getFieldName().equals("可修改邮箱")) {
                property.put("f2", "带实名邮箱");
            } else if(gameAttribute.getFieldName().equals("未绑定邮箱")) {
                property.put("f2", "未绑定邮箱");
            }else{
                property.put("f2", "死邮");
            }
            if(StringUtils.isNotEmpty(goodsInfoAndAttrValueDto.getF3())) {
                GameAttribute gameAttribute1 = gameAttributeMapper.selectGameAttributeById(Long.valueOf(goodsInfoAndAttrValueDto.getF3()));
                property.put("f3", gameAttribute1.getFieldName());
            }
            if(gameAttribute.getFieldName().contains("实名是本人")) {
                property.put("f4", "实名是本人");
            }else{
                property.put("f4", "实名非本人");
            }
            List<String> list6 = new ArrayList<>();
            List<String> list5 = new ArrayList<>();
            List<String> list4 = new ArrayList<>();
            List<String> list3 = new ArrayList<>();
            List<String> list2 = new ArrayList<>();
            List<String> list1 = new ArrayList<>();
            List<String> list0 = new ArrayList<>();
            List<String> wqList5 = new ArrayList<>();
            List<String> wqList4 = new ArrayList<>();
            List<String> wqList3 = new ArrayList<>();
            List<String> wqList2 = new ArrayList<>();
            List<String> wqList1 = new ArrayList<>();
            JSONObject data = JSONObject.parseObject(JSONObject.parseObject(getAtta("809")).getString("data"));
            if(StringUtils.isNotEmpty(goodsInfoAndAttrValueDto.getF11())) {
                List<GameAttribute> jsList = getGameAttributs(goodsInfoAndAttrValueDto.getF11());
                JSONObject f5 = JSONObject.parseObject(data.getString("f5"));
                JSONArray jsonArray2 = JSONArray.parseArray(f5.getString("options"));
                for(GameAttribute gameAttribute11 : jsList){
                    for(Object q:jsonArray2){
                        if(gameAttribute11.getFieldName().replace("满命","6命").contains(q.toString())){
                            list6.add(q.toString());
                        }
                    }
                }
                JSONObject f6 = JSONObject.parseObject(data.getString("f6"));
                JSONArray jsonArray6 = JSONArray.parseArray(f6.getString("options"));
                for(GameAttribute gameAttribute11 : jsList){
                    for(Object q:jsonArray6){
                        if(gameAttribute11.getFieldName().contains(q.toString())){
                            list5.add(q.toString());
                        }
                    }
                }
                JSONObject f7 = JSONObject.parseObject(data.getString("f7"));
                JSONArray jsonArray7 = JSONArray.parseArray(f7.getString("options"));
                for(GameAttribute gameAttribute11 : jsList){
                    for(Object q:jsonArray7){
                        if(gameAttribute11.getFieldName().contains(q.toString())){
                            list4.add(q.toString());
                        }
                    }
                }
                JSONObject f8 = JSONObject.parseObject(data.getString("f8"));
                JSONArray jsonArray8 = JSONArray.parseArray(f8.getString("options"));
                for(GameAttribute gameAttribute11 : jsList){
                    for(Object q:jsonArray8){
                        if(gameAttribute11.getFieldName().contains(q.toString())){
                            list3.add(q.toString());
                        }
                    }
                }
                JSONObject f9 = JSONObject.parseObject(data.getString("f9"));
                JSONArray jsonArray9 = JSONArray.parseArray(f9.getString("options"));
                for(GameAttribute gameAttribute11 : jsList){
                    for(Object q:jsonArray9){
                        if(gameAttribute11.getFieldName().contains(q.toString())){
                            list2.add(q.toString());
                        }
                    }
                }
                JSONObject f10 = JSONObject.parseObject(data.getString("f10"));
                JSONArray jsonArray10 = JSONArray.parseArray(f10.getString("options"));
                for(GameAttribute gameAttribute11 : jsList){
                    for(Object q:jsonArray10){
                        if(gameAttribute11.getFieldName().contains(q.toString())){
                            list1.add(q.toString());
                        }
                    }
                }
                JSONObject f11 = JSONObject.parseObject(data.getString("f11"));
                JSONArray jsonArray11 = JSONArray.parseArray(f11.getString("options"));
                for(GameAttribute gameAttribute11 : jsList){
                    for(Object q:jsonArray11){
                        if(gameAttribute11.getFieldName().contains(q.toString())){
                            list0.add(q.toString());
                        }
                    }
                }
            }
            if(StringUtils.isNotEmpty(goodsInfoAndAttrValueDto.getF17())) {
                List<GameAttribute> wqList = getGameAttributs(goodsInfoAndAttrValueDto.getF17());
                JSONObject f12 = JSONObject.parseObject(data.getString("f12"));
                JSONArray jsonArray3 = JSONArray.parseArray(f12.getString("options"));
                for (Object q : jsonArray3) {
                    for (GameAttribute gameAttribute11 : wqList) {
                        if (gameAttribute11.getFieldName().replace("精5", "5精").contains(q.toString())) {
                            wqList5.add(q.toString());
                        }
                    }
                }
                JSONObject f13 = JSONObject.parseObject(data.getString("f13"));
                JSONArray jsonArray13 = JSONArray.parseArray(f13.getString("options"));
                for (Object q : jsonArray13) {
                    for (GameAttribute gameAttribute11 : wqList) {
                        if (gameAttribute11.getFieldName().replace("精4", "4精").contains(q.toString())) {
                            wqList4.add(q.toString());
                        }
                    }
                }
                JSONObject f14 = JSONObject.parseObject(data.getString("f14"));
                JSONArray jsonArray14 = JSONArray.parseArray(f14.getString("options"));
                for (Object q : jsonArray14) {
                    for (GameAttribute gameAttribute11 : wqList) {
                        if (gameAttribute11.getFieldName().replace("精3", "3精").contains(q.toString())) {
                            wqList3.add(q.toString());
                        }
                    }
                }
                JSONObject f15 = JSONObject.parseObject(data.getString("f15"));
                JSONArray jsonArray15 = JSONArray.parseArray(f15.getString("options"));
                for (Object q : jsonArray15) {
                    for (GameAttribute gameAttribute11 : wqList) {
                        if (gameAttribute11.getFieldName().replace("精2", "2精").contains(q.toString())) {
                            wqList2.add(q.toString());
                        }
                    }
                }
                JSONObject f16 = JSONObject.parseObject(data.getString("f16"));
                JSONArray jsonArray16 = JSONArray.parseArray(f16.getString("options"));
                for (Object q : jsonArray16) {
                    for (GameAttribute gameAttribute11 : wqList) {
                        if (gameAttribute11.getFieldName().replace("精1", "1精").contains(q.toString())) {
                            wqList1.add(q.toString());
                        }
                    }
                }
            }
            if(list6.size()>0){
                property.put("f5", list6.toArray());
            }
            if(list5.size()>0){
                property.put("f6", list5.toArray());
            }
            if(list4.size()>0){
                property.put("f7", list4.toArray());
            }
            if(list3.size()>0){
                property.put("f8", list3.toArray());
            }
            if(list2.size()>0){
                property.put("f9", list2.toArray());
            }
            if(list1.size()>0){
                property.put("f10", list1.toArray());
            }
            if(list0.size()>0){
                property.put("f11", list0.toArray());
            }
            if(wqList5.size()>0){
                property.put("f12", wqList5.toArray());
            }
            if(wqList4.size()>0){
                property.put("f13", wqList4.toArray());
            }
            if(wqList3.size()>0){
                property.put("f14", wqList3.toArray());
            }
            if(wqList2.size()>0){
                property.put("f15", wqList2.toArray());
            }
            if(wqList1.size()>0){
                property.put("f16", wqList1.toArray());
            }

        }
        if (Objects.equals("英雄联盟", goodsInfoAndAttrValueDto.getGameName())) {
            params.put("game_id", 841);
            JSONObject jsonObject = JSONObject.parseObject(LDConstant.lol);
            String data = jsonObject.getString("data");
            List<JSONObject> jsonObjects = JSONObject.parseArray(data, JSONObject.class);
            for (JSONObject object : jsonObjects) {
                String name = object.getString("name");
                if (Objects.equals(name, goodsInfoAndAttrValueDto.getGroupName()+"区")) {
                    String servers = object.getString("servers");
                    List<JSONObject> serversList = JSONObject.parseArray(servers, JSONObject.class);
                    for (JSONObject server : serversList) {
                        String name1 = server.getString("name");
                        if (goodsInfoAndAttrValueDto.getServerName().equals(name1)) {
                            String id = server.getString("id");
                            params.put("server_id", id);
                        }
                    }
                }
            }
            if(StringUtils.isNotEmpty(goodsInfoAndAttrValueDto.getF2())){
                GameAttribute gameAttribute1 = gameAttributeMapper.selectGameAttributeById(Long.valueOf(goodsInfoAndAttrValueDto.getF2()));
                JSONObject data1 = JSONObject.parseObject(JSONObject.parseObject(getAtta("841")).getString("data"));
                JSONObject f1 = JSONObject.parseObject(data1.getString("f1"));
                JSONArray jsonArray2 = JSONObject.parseArray(f1.getString("options"));
                for(Object q : jsonArray2){
                    if(q.toString().contains(gameAttribute1.getFieldName())){
                        property.put("f1", q.toString());
                    }
                }
            }else{
                property.put("f1", "当前赛季无排位");
            }
            property.put("f2", "当前赛季无排位");
            property.put("f3", "当前赛季无排位");
            property.put("f4", "QQ等级0级");
            property.put("f5", "有QQ好友");
            property.put("f6", "30");
            property.put("f7", goodsInfoAndAttrValueDto.getF3());
            property.put("f8", goodsInfoAndAttrValueDto.getF4());
        }
        if(Objects.equals("火影忍者", goodsInfoAndAttrValueDto.getGameName())){
            params.put("game_id", 209);
            if (Objects.equals("安卓QQ", goodsInfoAndAttrValueDto.getSystemName()+goodsInfoAndAttrValueDto.getCarrierName())) {
                params.put("server_id", 95558);
            } else if (Objects.equals("安卓微信", goodsInfoAndAttrValueDto.getSystemName()+goodsInfoAndAttrValueDto.getCarrierName())) {
                params.put("server_id", 95561);
            } else if (Objects.equals("苹果微信", goodsInfoAndAttrValueDto.getSystemName()+goodsInfoAndAttrValueDto.getCarrierName())) {
                params.put("server_id", 95560);
            } else if (Objects.equals("苹果QQ", goodsInfoAndAttrValueDto.getSystemName()+goodsInfoAndAttrValueDto.getCarrierName())) {
                params.put("server_id", 95559);
            }
            if(gameAttribute.getFieldName().equals("可改二次")) {
                property.put("f1", "有二次实名");
            }else{
                property.put("f1", "无二次实名");
            }
            String response = getAtta("209");
            String data = JSONObject.parseObject(response).getString("data");
            List<String> srzList = new ArrayList<>();
            List<String> arzList = new ArrayList<>();
            JSONObject jsonObject = JSONObject.parseObject(data);
            if(StringUtils.isNotEmpty(goodsInfoAndAttrValueDto.getF5())){
                List<GameAttribute> slist = getGameAttributs(goodsInfoAndAttrValueDto.getF5());
                if(CollectionUtils.isNotEmpty(slist)) {
                    JSONObject jsonObject1 = JSONObject.parseObject(jsonObject.getString("f2"));
                    JSONArray jsonArray1 = JSONArray.parseArray(jsonObject1.getString("options"));
                    for (GameAttribute gameAttribute1 : slist) {
                        for (Object p : jsonArray1) {
                            if (p.toString().replace("「", "").replace("」", "").contains(gameAttribute1.getFieldName())) {
                                srzList.add(p.toString());
                            }
                        }
                    }
                }else{
                    srzList.add("无S级忍者");
                }
            }else{
                srzList.add("无S级忍者");
            }
            if(StringUtils.isNotEmpty(goodsInfoAndAttrValueDto.getF6())){
                List<GameAttribute> alist = getGameAttributs(goodsInfoAndAttrValueDto.getF6());
                if(CollectionUtils.isNotEmpty(alist)) {
                    JSONObject jsonObject1 = JSONObject.parseObject(jsonObject.getString("f3"));
                    JSONArray jsonArray1 = JSONArray.parseArray(jsonObject1.getString("options"));
                    for (GameAttribute gameAttribute1 : alist) {
                        for (Object p : jsonArray1) {
                            if (p.toString().contains(gameAttribute1.getFieldName())) {
                                arzList.add(p.toString());
                            }
                        }
                    }
                }else{
                    arzList.add("无A级忍者");
                }
            }else{
                arzList.add("无A级忍者");
            }
            property.put("f2", srzList);
            property.put("f3", arzList);
            property.put("f5", "是本人实名");
            if(StringUtils.isNotEmpty(goodsInfoAndAttrValueDto.getF3())){
                GameAttribute gameAttribute1 = gameAttributeMapper.selectGameAttributeById(Long.valueOf(goodsInfoAndAttrValueDto.getF3()));
                property.put("f6", gameAttribute1.getFieldName());
            }else{
                property.put("f6", "无");
            }
        }

        BigDecimal bigDecimal = commonApi.addPrice(goodsInfoAndAttrValueDto.getPrice(), salePartner.getSeleep());
        commonApi.setPrice(bigDecimal, goodsInfoAndAttrValueDto.getId(), salePartner);
        params.put("price", bigDecimal.setScale(BigDecimal.ROUND_UP, 0));
        String des = goodsInfoAndAttrValueDto.getDes();
        if (des.length() > 200) {
            des = des.substring(0, 200);
        }
        params.put("title", "【"+descTitle+"_"+goodsInfoAndAttrValueDto.getId() + "】" + regional + " " + gameAttribute.getFieldName() + des);
        params.put("description","【"+descTitle+"_"+goodsInfoAndAttrValueDto.getId() + "】" + gameAttribute.getFieldName() + goodsInfoAndAttrValueDto.getDes());


        GoodsInfoImg goodsInfoImg = new GoodsInfoImg();
        goodsInfoImg.setGoodsId(goodsInfoAndAttrValueDto.getId());
        goodsInfoImg.setType(Constants.STR_1);
        List<GoodsInfoImg> infoImgs = goodsInfoImgMapper.selectGoodsInfoImgList(goodsInfoImg);
        String imgs = "";
        if (!CollectionUtils.isEmpty(infoImgs)) {
            imgs = infoImgs.stream().map(i -> i.getImgUrl()).collect(Collectors.joining(","));
        }
        if (StringUtils.isEmpty(imgs)) {
            imgs = salePartner.getTwoOther();
        }
        params.put("image", imgs);
        params.put("property", property);
        return params;
    }

    private String reIds(String allIds, String ids) {
        if (StringUtils.isNotEmpty(ids)) {
            if (StringUtils.isNotEmpty(allIds)) {
                allIds = allIds + "," + ids;
            } else {
                allIds = ids;
            }
        }
        return allIds;
    }

    private List<GameAttribute> getGameAttributs(String ids) {
        return gameAttributeMapper.selectGameAttributeListByIds((Long[]) ConvertUtils.convert(ids.split(","),
                Long.class));
    }

    @Override
    public AjaxResult delGame(GoodsInfoAndAttrValueDto goodsInfoAndAttrValueDto, SalePartner sa) {
        String rand_str = rand_str();
        Map<String, Object> params = new LinkedHashMap<>();
        params.put("appid", sa.getSaleKey());
        params.put("secret", sa.getOther());
        params.put("rand_str", rand_str);
        params.put("timestamp", new Date().getTime() / 1000);
        String cover = MapUntils.getCover(params);
        cover = cover.substring(0, cover.length() - 1);
        log.info("cover={}", cover);
        String sign = DigestUtils.md5Hex(cover);
        String sr = sign + rand_str;
        try {
            sr = SecuritySHA1Utils.shaEncode(sr);
        } catch (Exception e) {
            e.printStackTrace();
        }
        params.put("sign", sr);
        ArtRec artRecreq = new ArtRec();
        artRecreq.setConfig(sa.getId());
        artRecreq.setAccountId(goodsInfoAndAttrValueDto.getId());
        List<ArtRec> artRecs = artRecMapper.selectArtRecList(artRecreq);
        if(artRecs.size()>0) {
            params.put("id", artRecs.get(0).getOutid());
        }
        params.put("code", goodsInfoAndAttrValueDto.getId());
        String path = "api/goods/platform/under";

        log.info("老达删除接口请求参数={}", JSONObject.toJSONString(params));
        String response = HttpUtils.doPostForm(sa.getTwoOther() + path, params, null);
        if (StringUtils.isEmpty(response)) {
            throw new GlobalException("请求接口失败");
        }
        log.info("老达删除接口返回参数={}", JSONObject.toJSONString(response));
        JSONObject resultJson = JSONObject.parseObject(response);
        Map<String, Object> result = new HashMap<>();

        if (!"1".equals(resultJson.getString("code"))) {
            result.put("code", 500);
        } else {
            result.put("code", 200);
            if(artRecs.size()>0){
                artRecMapper.deleteArtRecById(artRecs.get(0).getId());
            }
        }

        result.put("req", JSONObject.toJSONString(params));
        result.put("res", response);
        result.put("msg", resultJson.getString("data"));
        return AjaxResult.success(result);
    }


    private String rand_str() {

        long time = new Date().getTime();
        String s = String.valueOf(time);
        s = s.substring(7, s.length());
        return s;
    }


    public static void main(String[] args) {

        long time = new Date().getTime();
        String s = String.valueOf(time);
        String rand_str = "574159";

        String ss = "appid=xiaoyangren&secret=wrU8RKG18KDnzmjbpagVDpUOzdsix8&rand_str=574159&timestamp=1677918574";

        Map<String, Object> params = new LinkedHashMap<>();
        params.put("appid", "xiaoyangren");
        params.put("secret", "wrU8RKG18KDnzmjbpagVDpUOzdsix8");
        params.put("rand_str", rand_str);
        params.put("timestamp", "1677918574");
        String cover = MapUntils.getCover(params);
        cover = cover.substring(0, cover.length() - 1);
        log.info("cover={}", cover);
        String sign = DigestUtils.md5Hex(cover);
        String sr = sign + rand_str;
        log.info("sr={}", sr);
        try {
            sr = SecuritySHA1Utils.shaEncode(sr);
        } catch (Exception e) {
            e.printStackTrace();
        }
//        log.info("sign={}", sign);
//        log.info("sr={}", sr);
//        params.put("sign", sr);
//        String baseUrl = "http://api.dev.ldds.com/";
////        String urlGames = "api/goods/platform/servers";
//        String urlGames = "api/goods/platform/property";
//
//        params.put("game_id", "663");
//        System.out.println(JSONObject.toJSONString(params));
//        String response = HttpUtils.doPostForm(baseUrl + urlGames, params, null);
//
//        System.out.println(response);

//        String response = getAtta("204");
//
//        JSONObject jsonObject = JSONObject.parseObject(JSONObject.parseObject(getAtta("663")).getString("data"));
//        System.out.println(response);
        String response = getGame();
        System.out.println(response);

        //获取所有游戏
        //{"code":1,"msg":"成功","time":1677920839,"data":[{"id":95464,"name":"绝地求生"},{"id":204,"name":"和平精英"},{"id":663,"name":"王者荣耀"},{"id":813,"name":"永劫无间"},{"id":59,"name":"穿越火线"},{"id":809,"name":"原神"},{"id":95467,"name":"APEX英雄"},{"id":841,"name":"英雄联盟"}]}
        //{"code":1,"msg":"成功","time":1677921504,"data":[{"id":664,"name":"王者荣耀安卓版","servers":[{"id":70582,"name":"QQ"},{"id":71058,"name":"微信"}]},{"id":665,"name":"王者荣耀苹果版","servers":[{"id":71402,"name":"QQ"},{"id":71536,"name":"微信"}]}]}
        //{"code":1,"msg":"成功","time":1677921643,"data":[{"id":205,"name":"和平精英安卓版","servers":[{"id":23401,"name":"QQ"},{"id":23404,"name":"微信"}]},{"id":206,"name":"和平精英IOS版","servers":[{"id":23407,"name":"QQ"},{"id":23410,"name":"微信"}]}]}
        //{"code":1,"msg":"成功","time":1677930227,"data":[{"id":95523,"name":"网通区","servers":[{"id":95545,"name":"巨龙之巢"},{"id":95546,"name":"扭曲丛林"},{"id":95547,"name":"恕瑞玛"},{"id":95548,"name":"无畏先锋"},{"id":95549,"name":"弗雷尔卓德"},{"id":95550,"name":"德玛西亚"},{"id":95551,"name":"比尔吉沃特"}]},{"id":95524,"name":"全网络大区","servers":[{"id":95554,"name":"男爵领域"},{"id":95553,"name":"峡谷之巅"}]},{"id":95525,"name":"其他","servers":[{"id":95552,"name":"教育网专区"}]},{"id":95522,"name":"电信区","servers":[{"id":95541,"name":"钢铁烈阳"},{"id":95542,"name":"裁决之地"},{"id":95543,"name":"班德尔城"},{"id":95544,"name":"暗影岛"},{"id":95540,"name":"黑色玫瑰"},{"id":95539,"name":"祖安"},{"id":95538,"name":"诺克萨斯"},{"id":95537,"name":"皮尔特沃夫"},{"id":95536,"name":"战争学院"},{"id":95535,"name":"巨神峰"},{"id":95534,"name":"雷瑟守备"},{"id":95533,"name":"水晶之痕"},{"id":95532,"name":"均衡教派"},{"id":95531,"name":"艾欧尼亚"},{"id":95530,"name":"守望之海"},{"id":95529,"name":"征服之海"},{"id":95528,"name":"卡拉曼达"},{"id":95527,"name":"皮城警备"},{"id":95526,"name":"影流"}]}]}
    }

    static String getAtta(String gameId){
        Map<String, Object> params = new LinkedHashMap<>();
        String rand_str = "574159";
        params.put("appid", "yiyou");
        params.put("secret", "XxjPKdkM7izzExnZRtpRTRwwzZ3BAP7W");
        params.put("rand_str", rand_str);
        params.put("timestamp", "1677918574");
        String cover = MapUntils.getCover(params);
        cover = cover.substring(0, cover.length() - 1);
        String sign = DigestUtils.md5Hex(cover);
        String sr = sign + rand_str;
        try {
            sr = SecuritySHA1Utils.shaEncode(sr);
        } catch (Exception e) {
            e.printStackTrace();
        }
        params.put("sign", sr);
        String baseUrl = "http://newapi.ldds.com/";
        String urlGames = "api/goods/platform/property";
        params.put("game_id", gameId);
        String response = HttpUtils.doPostForm(baseUrl + urlGames, params, null);
        return response;
    }

    static String getGame(){
        Map<String, Object> params = new LinkedHashMap<>();
        String baseUrl = "http://newapi.ldds.com/";
        String urlGames = "api/goods/platform/games";
        String rand_str = "574159";
        params.put("appid", "zuyoule");
        params.put("secret", "4OJcHptFGmNUFXTgPIXXk04zWglsNjup");
        params.put("rand_str", rand_str);
        params.put("timestamp", "1677918574");
        String cover = MapUntils.getCover(params);
        cover = cover.substring(0, cover.length() - 1);
        String sign = DigestUtils.md5Hex(cover);
        String sr = sign + rand_str;
        try {
            sr = SecuritySHA1Utils.shaEncode(sr);
        } catch (Exception e) {
            e.printStackTrace();
        }
        params.put("sign", sr);
        String response = HttpUtils.doPostForm(baseUrl + urlGames, params, null);
        return response;
    }

    static String getArea(String gameId){
        Map<String, Object> params = new LinkedHashMap<>();
        String rand_str = "574159";
        params.put("appid", "yiyou");
        params.put("secret", "XxjPKdkM7izzExnZRtpRTRwwzZ3BAP7W");
        params.put("rand_str", rand_str);
        params.put("timestamp", "1677918574");
        String cover = MapUntils.getCover(params);
        cover = cover.substring(0, cover.length() - 1);
        String sign = DigestUtils.md5Hex(cover);
        String sr = sign + rand_str;
        try {
            sr = SecuritySHA1Utils.shaEncode(sr);
        } catch (Exception e) {
            e.printStackTrace();
        }
        params.put("sign", sr);
        String baseUrl = "http://newapi.ldds.com/";
        String urlGames = "api/goods/platform/servers";
        params.put("game_id", gameId);
        String response = HttpUtils.doPostForm(baseUrl + urlGames, params, null);
        return response;
    }

}
